home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / Emulation_Include_Files / kfuncs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  14.8 KB  |  457 lines

  1. /*++
  2.  
  3. Copyright (c) 1995-1998 Microsoft Corporation
  4.  
  5. Module Name: kfuncs.h
  6.  
  7. ++*/
  8.  
  9. #ifndef __KFUNCS_H__
  10. #define __KFUNCS_H__
  11.  
  12. #define NUM_SYS_HANDLES  32
  13.  
  14. #define SYS_HANDLE_BASE     64
  15. #define SH_WIN32                0
  16. #define SH_CURTHREAD            1
  17. #define SH_CURPROC              2
  18. // #define SH_KWIN32            3       // OBSOLETE
  19.  
  20. #define SH_LAST_NOTIFY            16    // Last set notified on Thread/Process Termination
  21. #define SH_GDI                  16
  22. #define SH_WMGR                 17
  23. #define SH_INIT                 18
  24. #define SH_COMM                 19      // Communications not "COM"
  25. #define SH_FILESYS_APIS            20      // File system APIS
  26. #define SH_SHELL                21
  27. #define SH_DEVMGR_APIS            22        // File system device manager
  28. #define SH_TAPI                    23
  29. #define SH_PATCHER                24
  30. #define SH_IMM                    25
  31. #define SH_WNET                    26      // WNet APIs for network redirector
  32.  
  33. #ifdef WINCEOEM
  34. #include <psyscall.h>    // change to include only defines required by OEMs
  35. #endif
  36.  
  37. #if defined(ARM)
  38. #define PUserKData ((LPBYTE)0xFFFFC800)
  39. #else
  40. #define PUserKData ((LPBYTE)0x00005800)
  41. #endif
  42. #define SYSHANDLE_OFFSET 0x004
  43.  
  44. #ifdef WINCEOEM
  45. #include <pkfuncs.h>    // change to include only defines required by OEMs
  46. #ifdef WINCEMACRO
  47. #include <mkfuncs.h>
  48. #endif
  49. #endif
  50.  
  51. #ifndef EventModify
  52. BOOL WINAPI EventModify(HANDLE hEvent, DWORD func);
  53. #endif
  54.  
  55. #if defined(MIPS)
  56.  
  57. #if defined(MIPS16SUPPORT) && !defined(NOMIPS16CODE)
  58. extern void DebugBreak();
  59. #pragma intrinsic (DebugBreak)
  60. #else
  61. extern void __asm(char[], ...);
  62. _inline void DebugBreak() {
  63.     __asm("break 1");
  64. }
  65. #endif
  66.  
  67. #elif defined(PPC)
  68.  
  69. void __emit(unsigned const __int32);
  70. _inline void DebugBreak() {
  71.     __emit(0x0FE00016);    // "twi 31,0,0x16"
  72. }
  73.  
  74. #elif defined(x86) || defined(_X86_)
  75.  
  76. _inline void DebugBreak() {
  77.     __asm int 3
  78. }
  79.  
  80. #elif defined(SHx)
  81.  
  82. extern void __asm(const char *, ...);
  83. #define DebugBreak() __asm("trapa #1")
  84.  
  85. #elif defined(ARM)
  86.  
  87. void __emit(unsigned const __int32);
  88. #define DebugBreak() __emit(0xE6000010)
  89.  
  90. #else
  91.  
  92. extern void DebugBreak();
  93.  
  94. #endif
  95.  
  96. #define EVENT_PULSE     1
  97. #define EVENT_RESET     2
  98. #define EVENT_SET       3
  99.  
  100. /*
  101.     @doc BOTH EXTERNAL
  102.     
  103.     @func BOOL | PulseEvent | Provides a single operation that sets (to signaled) the state 
  104.     of the specified event object and then resets it (to nonsignaled) after releasing the 
  105.     appropriate number of waiting threads. 
  106.     @parm HANDLE | hEvent | handle of event object 
  107.  
  108.     @comm Follows the Win32 reference description with the following exception:
  109. */
  110. _inline BOOL PulseEvent(HANDLE h) {
  111.     return EventModify(h,EVENT_PULSE);
  112. }
  113.  
  114. /*
  115.     @doc BOTH EXTERNAL
  116.     
  117.     @func BOOL | ResetEvent | Sets the state of the specified event object to nonsignaled. 
  118.     @parm HANDLE | hEvent | handle of event object 
  119.  
  120.     @comm Follows the Win32 reference description with the following exception:
  121. */
  122. _inline BOOL ResetEvent(HANDLE h) {
  123.     return EventModify(h,EVENT_RESET);
  124. }
  125.  
  126. /*
  127.     @doc BOTH EXTERNAL
  128.     
  129.     @func BOOL | SetEvent | Sets the state of the specified event object to signaled. 
  130.     @parm HANDLE | hEvent | handle of event object 
  131.  
  132.     @comm Follows the Win32 reference description with the following exception:
  133. */
  134. _inline BOOL SetEvent(HANDLE h) {
  135.     return EventModify(h,EVENT_SET);
  136. }
  137.  
  138. /*
  139.     @doc BOTH EXTERNAL
  140.     @func HANDLE | CreateEvent | Creates a named or unnamed event object. 
  141.     @parm LPSECURITY_ATTRIBUTES | lpEventAttributes | address of security attributes (<p must be NULL>). 
  142.     @parm BOOL | bManualReset | flag for manual-reset event 
  143.     @parm BOOL | bInitialState | flag for initial state 
  144.     @parm LPTSTR | lpName | address of event-object name (<p must be NULL>)
  145.     @comm Follows the Win32 reference description with these restrictions:
  146.     Only default security attributes are available and existing object names are not supported. 
  147.     The <p lpEventAttributes> and <p lpName> parameters must be set to NULL. 
  148.  
  149. */
  150.  
  151. /*
  152.     @doc BOTH EXTERNAL
  153.     @func VOID | Sleep | Suspends the execution of the current thread for a specified interval. 
  154.     @parm DWORD | cMilliseconds | sleep time in milliseconds 
  155.     @comm Follows the Win32 reference description without restrictions or modifications. 
  156. */
  157.  
  158. /*
  159.     @doc BOTH EXTERNAL
  160.     @func DWORD | WaitForSingleObject | Returns when the specified object is in the 
  161.     signaled state or when the time-out interval elapses. 
  162.     @parm HANDLE | hObject | <p See restrictions below> Handle of object to wait for 
  163.     @parm DWORD | dwTimeout | time-out interval in milliseconds  
  164.     @comm Follows the Win32 reference description without restriction
  165. */
  166.  
  167. /*
  168.     @doc BOTH EXTERNAL
  169.     @func DWORD | WaitForMultipleObjects | Returns when one of the specified objects is in the 
  170.     signaled state or when the time-out interval elapses.
  171.     @parm DWORD | cObjects | number of objects to wait on, must be less than MAXIMUM_WAIT_OBJECTS
  172.     @parm const HANDLE* | lphObjects | array of handles to wait on
  173.     @parm BOOL | fWaitAll | must be FALSE
  174.     @parm DWORD | dwTimeout | time-out interval in milliseconds  
  175.     @comm Follows the Win32 reference description with these restrictions:
  176.         bWaitAll must be FALSE
  177. */
  178.  
  179. /*
  180.     @doc BOTH EXTERNAL
  181.     @func DWORD | SuspendThread | Suspends the specified thread. 
  182.     @parm HANDLE | hThread | handle to the thread 
  183.     @comm Follows the Win32 reference description without restrictions or modifications. 
  184. */
  185.  
  186. /*
  187.     @doc BOTH EXTERNAL
  188.     @func DWORD | ResumeThread | Decrements a thread's suspend count. When the suspend count 
  189.             is decremented to zero, the execution of the thread is resumed. 
  190.     @parm HANDLE | hThread | identifies thread to restart 
  191.     @comm Follows the Win32 reference description without restrictions or modifications. 
  192. */
  193.  
  194. /*
  195.     @doc BOTH EXTERNAL
  196.     @func BOOL | SetThreadPriority | Sets the priority value for the specified thread. 
  197.     This value, together with the priority class of the thread's process, determines 
  198.     the thread's base priority level.
  199.     @comm Follows the Win32 reference description without restrictions or modifications. 
  200. */
  201.  
  202. /*
  203.     @doc BOTH EXTERNAL
  204.     @func int | GetThreadPriority | Returns the priority value for the specified thread.
  205.     @parm HANDLE | hThread | handle to thread 
  206.     @comm Follows the Win32 reference description without restrictions or modifications. 
  207. */
  208.  
  209.  
  210. /*
  211.     @doc BOTH EXTERNAL
  212.     @func DWORD | GetLastError | Returns the calling thread's last-error code value. 
  213.     @comm Follows the Win32 reference description without restrictions or modifications. 
  214. */
  215.  
  216. /*
  217.     @doc BOTH EXTERNAL
  218.     @func VOID | SetLastError | Sets the last-error code for the calling thread. 
  219.     @parm DWORD | fdwError | per-thread error code  
  220.     @comm Follows the Win32 reference description without restrictions or modifications. 
  221. */
  222.  
  223. /*
  224.     @doc BOTH EXTERNAL
  225.     @func BOOL | GetExitCodeThread | Retrieves the termination status of the specified thread. 
  226.     @parm HANDLE | hThread | handle to the thread 
  227.     @parm LPDWORD |lpdwExitCode | address to receive termination status 
  228.     @comm Follows the Win32 reference description without restrictions or modifications. 
  229. */
  230.  
  231. /*
  232.     @doc BOTH EXTERNAL
  233.     @func HANDLE | GetCurrentThread | Returns a pseudohandle for the current thread.
  234.     @comm Follows the Win32 reference description without restrictions or modifications.
  235. */
  236.  
  237. #ifdef _WIN32_WCE_EMULATION
  238. HANDLE WINAPI GetCurrentThread(void);
  239. #else
  240. _inline HANDLE GetCurrentThread(void) {
  241.     return ((HANDLE)(SH_CURTHREAD+SYS_HANDLE_BASE));
  242. }
  243. #endif
  244.  
  245. /*
  246.     @doc BOTH EXTERNAL
  247.     @func HANDLE | GetCurrentProcess | Returns a pseudohandle for the current process.
  248.     @comm Follows the Win32 reference description without restrictions or modifications.
  249. */
  250.  
  251. #ifdef _WIN32_WCE_EMULATION
  252. HANDLE WINAPI GetCurrentProcess(void);
  253. #else
  254. _inline HANDLE GetCurrentProcess(void) {
  255.     return ((HANDLE)(SH_CURPROC+SYS_HANDLE_BASE));
  256. }
  257. #endif
  258.  
  259. #ifdef _WIN32_WCE_EMULATION
  260. DWORD WINAPI GetCurrentThreadId(void);
  261. #else
  262. _inline DWORD GetCurrentThreadId(void) {
  263.     return ((DWORD)(((HANDLE *)(PUserKData+SYSHANDLE_OFFSET))[SH_CURTHREAD]));
  264. }
  265. #endif
  266.  
  267. #ifdef _WIN32_WCE_EMULATION
  268. DWORD WINAPI GetCurrentProcessId(void);
  269. #else
  270. _inline DWORD GetCurrentProcessId(void) {
  271.     return ((DWORD)(((HANDLE *)(PUserKData+SYSHANDLE_OFFSET))[SH_CURPROC]));
  272. }
  273. #endif
  274.  
  275. #define TLS_FUNCALLOC   0
  276. #define TLS_FUNCFREE    1
  277.  
  278. #ifndef TlsCall
  279. DWORD WINAPI TlsCall(DWORD p1, DWORD p2);
  280. #endif
  281.  
  282. /*
  283.     @doc BOTH EXTERNAL
  284.     @func DWORD | TlsAlloc | Allocates a thread local storage (TLS) index. Any thread 
  285.         of the process can subsequently use this index to store and retrieve values that 
  286.         are local to the thread.
  287.     @comm Follows the Win32 reference description without restrictions or modifications. 
  288. */
  289.  
  290. _inline DWORD WINAPI TlsAlloc(void) {
  291.     return TlsCall(TLS_FUNCALLOC, 0);
  292. }
  293.  
  294. /*
  295.     @doc BOTH EXTERNAL
  296.     @func BOOL | TlsFree | Releases a thread local storage (TLS) index, making it available 
  297.         for reuse. 
  298.     @parm DWORD | dwTlsIndex | TLS index to free  
  299.     @comm Follows the Win32 reference description without restrictions or modifications. 
  300. */
  301. _inline BOOL WINAPI TlsFree(DWORD dwTlsIndex) {
  302.     return TlsCall(TLS_FUNCFREE, dwTlsIndex);
  303. }
  304.  
  305. #define VERIFY_READ_FLAG    0
  306. #define VERIFY_EXECUTE_FLAG 0
  307. #define VERIFY_WRITE_FLAG   1
  308. #define VERIFY_KERNEL_OK    2
  309.  
  310. /*
  311.     @doc BOTH EXTERNAL
  312.     @func BOOL | IsBadReadPtr | Verifies that the calling process 
  313.         has read access to the specified range of memory. 
  314.     @parm CONST VOID | *lpvPtr | address of memory block 
  315.     @parm UINT | cbBytes | size of block 
  316.     @comm Follows the Win32 reference description without restrictions or modifications. 
  317. */
  318.  
  319. /*
  320.     @doc BOTH EXTERNAL
  321.     @func BOOL | IsBadWritePtr | Verifies that the calling process has write access 
  322.         to the specified range of memory. 
  323.     @parm LPVOID | lpvPtr | address of memory block  
  324.     @parm UINT | cbBytes | size of block 
  325.     @comm Follows the Win32 reference description without restrictions or modifications. 
  326. */
  327.  
  328. /*
  329.     @doc BOTH EXTERNAL
  330.     @func LPVOID | VirtualAlloc | Reserves or commits a region of pages in the virtual 
  331.         address space of the calling process. Memory allocated by this function is automatically 
  332.         initialized to zero. 
  333.     @parm LPVOID | lpvAddress | address of region to reserve or commit  
  334.     @parm DWORD | cbSize | size of region 
  335.     @parm DWORD | fdwAllocationType | type of allocation 
  336.     @parm DWORD | fdwProtect | type of access protection 
  337.     @comm Follows the Win32 reference description without restrictions or modifications. 
  338. */
  339.  
  340. /*
  341.     @doc BOTH EXTERNAL
  342.     @func BOOL | VirtualFree | Releases or decommits (or both) a region of pages 
  343.     within the virtual address space of the calling process. 
  344.     @parm LPVOID | lpvAddress | address of region of committed pages  
  345.     @parm DWORD | cbSize | size of region 
  346.     @parm DWORD | fdwFreeType | type of free operation 
  347.     @comm Follows the Win32 reference description without restrictions or modifications. 
  348. */
  349.  
  350. /*
  351.     @doc BOTH EXTERNAL
  352.     @func BOOL | VirtualProtect | Changes the access protection on a region of committed 
  353.         pages in the virtual address space of the calling process. This function differs 
  354.         from VirtualProtectEx, which changes the access protection of any process.
  355.     @parm LPVOID | lpvAddress | address of region of committed pages 
  356.     @parm DWORD | cbSize | size of the region 
  357.     @parm DWORD | fdwNewProtect | desired access protection 
  358.     @parm PDWORD | pfdwOldProtect | address of variable to get old protection  
  359.     @comm Follows the Win32 reference description without restrictions or modifications. 
  360. */
  361.  
  362. /*
  363.     @doc BOTH EXTERNAL
  364.     @func DWORD | VirtualQuery | Information about a range of pages in the virtual 
  365.         address space of the calling process. 
  366.     @parm LPCVOID | lpvAddress | address of region 
  367.     @parm MEMORY_BASIC_INFORMATION | pmbiBuffer | address of information buffer  
  368.     @parm DWORD | cbLength | size of buffer 
  369.     @comm Follows the Win32 reference description without restrictions or modifications. 
  370. */
  371.     
  372. /*
  373.     @doc BOTH EXTERNAL
  374.     @func HINSTANCE | LoadLibrary | Maps the specified executable module into the address 
  375.         space of the calling process.
  376.     @parm LPTSTR | lpszLibFile | address of filename of executable module 
  377.     @comm Follows the Win32 reference description without restrictions or modifications. 
  378. */
  379.  
  380. /*
  381.     @doc BOTH EXTERNAL
  382.     
  383.     @func BOOL | FreeLibrary | Decrements the reference count of the loaded dynamic-link 
  384.         library (DLL) module
  385.     @parm HMODULE |hLibModule | handle of loaded library module  
  386.     @comm Follows the Win32 reference description without restrictions or modifications. 
  387.     @devnote Follows the Win32 reference description without restrictions or modifications
  388. */
  389.  
  390. /*
  391.     @doc BOTH EXTERNAL
  392.     @func FARPROC | GetProcAddress | Returns the address of the specified exported dynamic-link 
  393.         library (DLL) function. 
  394.     @parm HMODULE | hModule | handle to DLL module  
  395.     @parm LPSTR | lpszProc | name of function 
  396.     @comm Follows the Win32 reference description without restrictions or modifications. 
  397. */
  398.  
  399. /*
  400.     @doc BOTH EXTERNAL
  401.     @func HRSRC | FindResource | Determines the location of a resource with the specified 
  402.         type and name in the specified module. 
  403.     @parm HMODULE |hModule | resource-module handle 
  404.     @parm LPTSTR | lpName | address of resource name  
  405.     @parm LPTSTR | lpType | address of resource type 
  406.     @comm Follows the Win32 reference description with the exception that we don't support
  407.         the resource id 0 (ie: FindResource(h,0,t) will not work as expected).
  408. */
  409.  
  410. /*
  411.     @doc BOTH EXTERNAL
  412.     @func HGLOBAL| LoadResource | Loads the specified resource into global memory. 
  413.     @parm HINSTANCE | hModule | resource-module handle  
  414.     @parm HRSRC | hResInfo | resource handle 
  415.     @comm Follows the Win32 reference description without restrictions or modifications. 
  416. */
  417.  
  418. /*
  419.     @doc BOTH EXTERNAL
  420.     @func LPVOID| LockResource | Locks a loaded resource
  421.     @parm HGLOBAL | hGlob | Locked resource's handle
  422.     @comm Follows the Win32 reference description without restrictions or modifications.
  423. */
  424.  
  425. #ifdef _WIN32_WCE_EMULATION
  426. LPVOID WINAPI LockResource(HGLOBAL hResData);
  427. #else
  428. _inline LPVOID LockResource(HGLOBAL hResData) {
  429.     return ((LPVOID)hResData);
  430. }
  431. #endif
  432.  
  433. /*
  434.     @doc BOTH EXTERNAL
  435.     @func DWORD | GetTickCount | Retrieves the number of milliseconds that have 
  436.         elapsed since Windows was started. 
  437.     @comm Follows the Win32 reference description without restrictions or modifications. 
  438. */
  439.  
  440. /*
  441.     @doc BOTH EXTERNAL
  442.     @func VOID | OutputDebugString| Sends a string to the debugger for the current application. 
  443.     @parm LPTSTR | lpszOutputString | address of string to be displayed  
  444.     @comm Follows the Win32 reference description with these restrictions:
  445.     @comm Supports only the Unicode version of this function.
  446. */
  447.  
  448. /*
  449.     @doc BOTH EXTERNAL
  450.     @func VOID | GetSystemInfo | Returns information about the current system. 
  451.     @parm LPSYSTEM_INFO | lpSystemInfo | address of system information structure  
  452.     @comm Follows the Win32 reference description without restrictions or modifications. 
  453. */
  454.  
  455. #endif
  456.  
  457.